<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统审计,操作日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<div style="margin: 10px">
    <table id="sysAuditTable" lay-filter="sysAuditTable"></table>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="sysAuditHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
            <a class="layui-btn layui-btn-sm" id="chart" lay-event="chart" style="display: none;">
                <i class="layui-icon layui-icon-chart"></i>
                <span>柱状日志图表</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="sysAuditQueryForm" style="margin-right: 30px;">
            <div class="layui-row" style="margin-top: 10px;">
                <div class="selch table-top-filter">
                    <div class="table-filter-alone">
                        <label class="layui-form-label">操作名称</label>
                        <input type="text" class="layui-input filter-value" name="Q_opname_SL" placeholder="操作名称"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">执行人ID</label>
                        <input type="text" class="layui-input filter-value" name="Q_executorid_SL" placeholder="执行人ID"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">执行人姓名</label>
                        <input type="text" class="layui-input filter-value" name="Q_executor_SL" placeholder="执行人姓名"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label" style="width:135px">执行人所在组织</label>
                        <input type="text" class="layui-input filter-value" name="Q_exeOrgName_SL" placeholder="执行人所在组织"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">开始时间</label>
                        <input type="text" class="layui-input start_time filter-value" name="Q_beginExetime_DL" placeholder="开始时间"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">结束时间</label>
                        <input type="text" class="layui-input end_time filter-value" name="Q_endExetime_DG" placeholder="结束时间"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">IP地址</label>
                        <input type="text" class="layui-input filter-value" name="Q_fromip_SL" placeholder="IP地址"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">所属模块</label>
                        <input type="text" class="layui-input filter-value" name="Q_ownermodel_SL" placeholder="所属模块"/>
                    </div>

                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="sysAuditRightToolsBar">
    <a class="layui-btn layui-btn-xs" lay-event="detail">明细</a>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'setter', 'form', 'common','totalFilter','commons','jquery'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var commons = layui.commons;
        var $ = layui.jquery;
        var layer = layui.layer;
        var totalFilter = layui.totalFilter;
        common.tableSort('sysAuditTable');

        var tableH=commons.tabHeight('full-70');
        var logLeave = "${logLeave}";

        //第一个实例
        table.render({
            elem: '#sysAuditTable'
            ,height:tableH
            ,url: serverPath.systemPath + setter.sysLinkPath + 'sysAudit/list?logLeave='+logLeave
            ,page: true //开启分页
            ,defaultToolbar: ['filter', 'print']
            ,toolbar: '#sysAuditHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                ,{type: 'checkbox', fixed: 'left'}
                ,{field: 'opname', title: '操作名称',sort:true, sortname: 'opname'}
                //当前转换后的格式为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.exetime,"1");
                //如需转换为HH:mm:ss: return commons.timeData(d.exetime,"2");
                // 如需转换为yyyy-MM-dd: return commons.timeData(d.exetime);
                ,{field: 'exetime', title: '执行时间',sort:true, sortname: 'exetime',templet: function (d) {
                    return component.timeData(d.exetime,"1");
                }}
                ,{field: 'executorid', title: '执行人ID',sort:true, sortname: 'executorid'}
                ,{field: 'executor', title: '执行人姓名',sort:true, sortname: 'executor'}
                ,{field: 'exeOrgName', title: '执行人所在组织',sort:true, sortname: 'exeOrgName'}
                ,{field: 'fromip', title: 'IP地址',sort:true, sortname: 'fromip'}
                ,{field: 'ownermodel', title: '所属模块',sort:true, sortname: 'ownermodel'}
                ,{field: 'exectype', title: '日志类型',sort:true, sortname: 'exectype'}
                ,{
                    fixed: 'right',
                    align: 'center',
                    title: '管理',
                    toolbar: '#sysAuditRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });

        totalFilter.init('sysAuditTable');
        commons.reflashDate({startName:'.start_time',endName:'.end_time'});

        function reflashQuery(isClear) {
            common.tableConditionRender("sysAuditTable","sysAuditQueryForm",{where:{}},isClear);
        }

        logLeaveToLoad();

        table.on('toolbar(sysAuditTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case "query":
                    reflashQuery(false);
                    commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                    logLeaveToLoad();
                    break;
                case "clears":
                    reflashQuery(true);
                    commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                    logLeaveToLoad();
                    break;
                case "chart":
                    layer.open({
                        type: 2,
                        area: ['800px', '500px'],
                        title: ['图表'],
                        content: serverPath.systemPath + setter.sysLinkPath + 'sysAudit/view/chart?logLeave='+logLeave
                    });
                    break;
            };
        });


        table.on('tool(sysAuditTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "detail":
                    layer.open({
                        type: 2,
                        area: ['1000px', '500px'],
                        title: ['详细信息'],
                        content: serverPath.systemPath + setter.sysLinkPath + 'sysAudit/view/add?auditid='+data.auditid
                    });
                    break;
            }
        });

        window.Initialization = function () {
            commons.reflashDate({startName:'.start_time',endName:'.end_time'});
        };
        /*刷新时间控件*/
        commons.reflashDate({startName:'.start_time',endName:'.end_time'});
        common.tableSort("sysAuditTable",{show:window.Initialization});

        function logLeaveToLoad() {
            if(logLeave == "0"){
                $("#chart").show();
            }
            if(logLeave == "1"){
                $("#chart").hide();
            }
        }

    });
</script>
</body>
</html>